package co.fitstart.admin.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import co.fitstart.admin.service.CoursewareTestService;
import co.fitstart.admin.service.DataService;
import co.fitstart.entity.courseware.fitnessgroup.FitnessGroup;

@Controller
@RequestMapping("/test-coursewares")
public class CoursewareTestController {
    
    @Autowired
    @Qualifier("dataService")
    private DataService<FitnessGroup> fitnessGroupService;
    
    @Autowired
    private CoursewareTestService testService;
    
    /**
     * 
     * @param groupId
     * @param changeId
     * @return
     */
    @RequestMapping(value = "", method = RequestMethod.GET)
    public ModelAndView test(@RequestParam("groupId") Long groupId, @RequestParam("changeId") Long changeId) {
        ModelAndView modelAndView = new ModelAndView("index");
        
        FitnessGroup group = fitnessGroupService.load(FitnessGroup.class, groupId);
        FitnessGroup change = fitnessGroupService.load(FitnessGroup.class, changeId);
        
        testService.changeGroup(group, change);
        
        return modelAndView;
    }

}
